<?php
/**
 * Created by PhpStorm.
 * User: DELL-PC
 * Date: 2018/9/7
 * Time: 15:44
 */

namespace Application\Admin\Controller;


use J\Schema\Syntax;
use J\Intent;
use J\MVC\Controller;

class SuperController extends Controller
{
    protected function beforeCore()
    {
        parent::beforeCore();
        $this->enableAdmin(self::AUTH_SUPER);
    }

    protected function optionElementUIInstall(Intent $intent)
    {
        $intent->value = [
            'view' => [
                'name' => Syntax::DISPLAY_FORM,
                'fields' => [
                    [
                        'index' => 'module-name',
                        'label' => '模块名',
                        'name'  => 'name',
                        'colWidth' => 200,
                    ],
                ],
                'url' => '/api.php/UserCenter/super/install'
            ]
        ];
    }

    protected function optionApiInstall(Intent $intent)
    {
        return $intent->jump('/' . trim($_REQUEST['name'], '/') . '/Install/Install');
    }

    protected function optionElementUIUninstall(Intent $intent)
    {
        $intent->value = [
            'view' => [
                'name' => Syntax::DISPLAY_FORM,
                'fields' => [
                    [
                        'index' => 'module-name',
                        'label' => '模块名',
                        'name' => 'name',
                        'colWidth' => 200,
                    ],
                ],
                'url' => '/api.php/UserCenter/super/uninstall'
            ]
        ];
    }

    protected function optionApiUninstall(Intent $intent)
    {
        return $intent->jump('/' . trim($_REQUEST['name'], '/') . '/install/Uninstall');
    }
}